package com.nf.service;

import com.nf.entity.Boss;
import com.nf.entity.Join;
import com.nf.mapper.BossMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class BossServiceImpl implements BossService {

   private BossMapper bossMapper;
   private BossMapper join=null;

   public Boss test(){
       SqlSession session = null;
       try {
           InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
           SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
           SqlSessionFactory sessionFactory = builder.build(inputStream);
           SqlSession sqlSession = sessionFactory.openSession();
           join =sqlSession.getMapper(BossMapper.class);

       } catch (IOException e) {
           e.printStackTrace();
       }
       return null;
   }
   public void test1(){
       test();
       List<Join> list =  join.selectjoin();
       for (Join join:list){
           System.out.print(join.getBname());
           System.out.println(join.getBpay());
           System.out.print(join.getSname());
           System.out.println(join.getSpay());

       }
   }
}
